package com.xl.juc.stream;

import org.springframework.util.StopWatch;

import java.util.stream.LongStream;

/**
 * 并行流求和
 * @author Charley
 * @create 2021-01-24
 */
public class ParallelStream {
    public static void main(String[] args) {
        //rangeClosed (] 包含结尾    range:() 不包含结尾
        StopWatch watch = new StopWatch();
        watch.start("开始计算");
        System.out.println( LongStream.rangeClosed(0L, 10_0000_0000L).reduce(0, Long::sum));
        watch.stop();
        System.out.println(watch.prettyPrint());
    }
}
